//
//  BCSEvent.swift
//  BCEventBus
//
//  Created by Basic on 2019/6/27.
//  BCEvent swift版本，功能和 RACSubject 一样


final public class BCSEvent<T> {
    
    /// next handle
    private var nextHandle:((_ model:T?)->())?
    
    public init() {
    }
    
    deinit {
        #if DEBUG
        NSLog("[eventbus] subject deinit")
        #endif
    }
    
    //MARK: - 设置next 方法
    public func setNext(_ action:@escaping ( (_ model:T?) -> ())) {
        self.nextHandle = action
    }
    
    //MARK: - 执行 next
    public func sendNext(_ model:T?) {
        guard  let nextHandle = self.nextHandle else {
            return
        }
        nextHandle(model)
    }
    
}
